
package com.craterhill.java.ems.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.craterhill.java.ems.common.beans.School;
import com.craterhill.java.ems.dao.SchoolDao;
import com.craterhill.java.ems.service.SchoolService;

@Service
public class SchoolServiceImpl implements SchoolService {

	@Autowired
	private SchoolDao schoolDao;

	@Override
	public School saveSchool(final School school) {
		int newSchoolId = schoolDao.save(school);
		school.setSchoolId(newSchoolId);
		return school;
	}

	@Override
	public boolean updateSchool(final School school) {
		return schoolDao.update(school);
	}

	@Override
	public boolean deleteSchool(final Integer... schoolIds) {
		return schoolDao.remove(schoolIds);
	}

	@Override
	public School getSchool(final int schoolId) {
		return schoolDao.find(schoolId);
	}

	@Override
	public List<School> getSchools() {
		return schoolDao.findAll();
	}
}
